#include "HelloWorldScene.h"
#include <cocostudio/CocoStudio.h>
using namespace cocostudio;
USING_NS_CC;

Scene* HelloWorld::createScene()
{
    // 'scene' is an autorelease object
    auto scene = Scene::create();
    
    // 'layer' is an autorelease object
    auto layer = HelloWorld::create();

    // add layer as a child to scene
    scene->addChild(layer);

    // return the scene
    return scene;
}

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    /*
	Sprite* bg = Sprite::create("bg_home.png");
	float scale = visibleSize.height / bg->getContentSize().height;
    bg->setScale(scale);
	this->addChild(bg, 0);

	Label* lbl = Label::create("hahaha", "abc", 30);
	lbl->setPosition(Vec2(visibleSize.width /2, visibleSize.height / 2));
	this->addChild(lbl, 1);

	std::string s = "CloseNormal.png";
	std::string fullPath = FileUtils::getInstance()->fullPathForFilename(s.c_str());
	lbl->setString(fullPath.c_str());*/

	auto node = CSLoader::getInstance()->createNode("MenuScene.csb");
	float scale = visibleSize.height / node->getContentSize().height;
    node->setScale(scale);
	this->addChild(node);

    return true;
}


void HelloWorld::menuCloseCallback(Ref* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
	MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
    return;
#endif

    Director::getInstance()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
}
